#include <iostream>
using namespace std;

const int N = 100010;
const int M = 1000010;
char p[N], s[M];
int ne[M];

int main()
{
    int n, m; 
    cin >> n >> p + 1 >> m >> s + 1;   //下标从1开始

    //构造next数组
    for (int i = 2, j = 0; i <= n; i++)
    {
        while (j && p[i] != p[j + 1]) j = ne[j];
        if (p[i] == p[j + 1]) j++;
        ne[i] = j;
    }

    //求解
    for (int i = 1, j = 0; i <= m; i++)
    {
        while (j && s[i] != p[j + 1]) j = ne[j];
        if (s[i] == p[j + 1]) j++;
        if (j == n) {
            cout << i - n << ' ';
            j = ne[j];
        }
    }
}